package ui.adapter;

import android.graphics.Color;
import android.text.SpannableStringBuilder;
import android.text.style.ForegroundColorSpan;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.fy.fyzf.R;
import com.fy.fyzf.base.BaseApp;
import com.fy.fyzf.bean.NearHousingBean;
import com.fy.fyzf.glideUtils.GlideUtils;
import com.fy.fyzf.utils.MathUtils;

import java.util.List;

public class NearFloorAdapter extends BaseQuickAdapter<NearHousingBean.ListBean, BaseViewHolder> {
    public NearFloorAdapter() {
        super(R.layout.item_near_floor);
    }

    @Override
    protected void convert(BaseViewHolder helper, NearHousingBean.ListBean item) {
        GlideUtils.loadImage(item.getFloorImage(), helper.getView(R.id.iv_logo));
        helper.setText(R.id.tv_name, item.getFloorName());
        if (null == item.getFloorImage()) {
            GlideUtils.loadRoundedCornersImage_Local(R.mipmap.housing_nodata, helper.getView(R.id.iv_logo), 10);
        } else {
            GlideUtils.loadSingleRadius(BaseApp.getContext(),10,item.getFloorImage(),helper.getView(R.id.iv_logo));
        }
        String s = MathUtils.rvZeroAndDot(item.getMinRentPrice()) + "元/m²/天";
        SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(s);
        spannableStringBuilder.setSpan(new ForegroundColorSpan(Color.parseColor("#FF7E00")), 0, MathUtils.rvZeroAndDot(item.getMinRentPrice()) .length(), spannableStringBuilder.SPAN_EXCLUSIVE_EXCLUSIVE);
        spannableStringBuilder.setSpan(new ForegroundColorSpan(Color.parseColor("#989897")), MathUtils.rvZeroAndDot(item.getMinRentPrice()) .length(), s.length(), spannableStringBuilder.SPAN_EXCLUSIVE_EXCLUSIVE);
        helper.setText(R.id.tv_price, spannableStringBuilder);
    }

}
